package cn.tude.boot07.controller;

import cn.tude.boot07.Mapper.WeiboMapper;
import cn.tude.boot07.entity.Weibo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.util.List;

@RestController
public class WeiboController {
    @Autowired
    WeiboMapper mapper;
@RequestMapping("/insert")
    public void insert(@RequestBody Weibo weibo){
    System.out.println("weibo = " + weibo);mapper.insert(weibo);
}
@RequestMapping("/select")
    public List<Weibo> select() {
return mapper.select();
}
@RequestMapping("/del")
   public void del(int id){
   String url=mapper.selectUrlById(id);
  new File("d:/files"+url).delete();
  mapper.delete(id);
}




}
